package com.ror.java.se.thread;

//线程池ExecutorService

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo12 {
    public static void main(String[] args) {
        ExecutorService pool1 = Executors.newFixedThreadPool(3);
        pool1.submit(Demo12::task1);
        pool1.submit(Demo12::task1);
        pool1.submit(Demo12::task1);
        pool1.submit(Demo12::task2); //线程池满了，等着
        pool1.submit(Demo12::task2); //线程池满了，等着
        pool1.shutdown();
    }

    private static void task1() {
        for (int i = 1; i <= 50; i++) {
            System.out.println(Thread.currentThread().getName() + "--task1-" + i);
        }
    }

    private static  void task2() {
        for (int i = 1; i <= 50; i++) {
            System.out.println(Thread.currentThread().getName() + "--task2-" + i);
        }
    }
}
